package net.lee.springbootvertx.controller;

import io.vertx.core.http.HttpMethod;
import io.vertx.rxjava.ext.web.RoutingContext;
import net.lee.springbootvertx.service.IHelloService;
import net.lee.springbootvertx.vertx.request.Controller;
import net.lee.springbootvertx.vertx.request.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@RequestMapping("/test")
@Controller
public class TestController {

    @Autowired
    IHelloService helloService;

    @RequestMapping(value = {"","/index"},requestMethod = {HttpMethod.GET,HttpMethod.POST})
    public void testInfo(RoutingContext routingContext)
    {
        String userName = routingContext.queryParam("username").stream().findFirst().orElse(null);
        routingContext.response().end(helloService.sayHello(userName));
    }

}
